package fsoft.com.vn.directory.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import fsoft.com.vn.directory.form.Address;
import fsoft.com.vn.directory.service.AddressService;

@Controller
public class AddressController {

	@Autowired
	private AddressService addressService;

	@RequestMapping("/address")
	public String listAddress(Map<String, Object> map) {
		map.put("address", new Address());
		List<Address> addressList = addressService.listAddress();
		map.put("addressList", addressList);
		return "address";
	}
	
	@RequestMapping("/searchaddress")
	public String search(Map<String, Object> map,@RequestParam(value = "postcode") String postcode, @RequestParam(value = "street") String street, @RequestParam(value = "town") String town) {
		map.put("address", new Address());
		map.put("addressList", addressService.search(postcode,street,town));
		return "address";
	}
	
	
}
